﻿using System;

namespace AIC_Notification
{
    public class Schedule
    {
        public DateTime StartDateTime;
        public DateTime EndDateTime;
        public DayOfWeek[] RunOnDays;
        
        public string[] args = null;

        public Schedule()
        {
        }
    }

    public class Scheduler
    {
        // public static IList<Schedule> Schedules = null;

        public virtual void Initizlize()
        {
        }

        public virtual void Set()
        {
        }
    }

    public class SOF_Scheduler: Scheduler
    {
        public override void Initizlize()
        {
            Statistics.ApplicationType = ApplicationType.sof;
        }

        public override void Set()
        {
            DateTime Today = DateTime.Now;
            int Month = Today.Month;
            int Day   = Today.Day;
            int Hour  = Today.Hour;
            DayOfWeek DayOfWeek = Today.DayOfWeek;

            Global.Reports.Clear();

            if (Month >= 7 && Month <= 8)
            {
                if (Hour < 12)
                {
                    if (DayOfWeek == DayOfWeek.Monday || DayOfWeek == DayOfWeek.Wednesday || DayOfWeek == DayOfWeek.Thursday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new TeacherStatusForLT());
                    }
                    else if (DayOfWeek == DayOfWeek.Tuesday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForLT());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else if (DayOfWeek == DayOfWeek.Friday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(true));
                        Global.Reports.Add(new EssayPendingReportForAM(true));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForStudent());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else
                    {
                        Statistics.RunType = RunType.update;
                    }
                }
                else
                {
                    Statistics.RunType = RunType.skip;
                }
            }
            else if ((Month >= 9 && Month <= 11) || (Month == 1) || (Month == 2 && Day <= 15))
            {
                if (Hour < 12)
                {
                    if (DayOfWeek == DayOfWeek.Monday || DayOfWeek == DayOfWeek.Wednesday || DayOfWeek == DayOfWeek.Thursday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new TeacherStatusForLT());
                    }
                    else if (DayOfWeek == DayOfWeek.Tuesday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForLT());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new SchoolListForAC());
                        Global.Reports.Add(new SchoolListForAM());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else if (DayOfWeek == DayOfWeek.Friday)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(true));
                        Global.Reports.Add(new EssayPendingReportForAM(true));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForStudent());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else
                    {
                        Statistics.RunType = RunType.update;
                    }
                }
                else
                {
                    Statistics.RunType = RunType.skip;
                }
            }
            else if (Month == 12)
            {
                if (DayOfWeek == DayOfWeek.Monday || DayOfWeek == DayOfWeek.Wednesday || DayOfWeek == DayOfWeek.Thursday || DayOfWeek == DayOfWeek.Saturday || DayOfWeek == DayOfWeek.Sunday)
                {
                    Statistics.RunType = RunType.full;
                    Global.Reports.Add(new EssayPendingReportForAC(false));
                    Global.Reports.Add(new EssayPendingReportForAM(false));
                    Global.Reports.Add(new TeacherStatusForLT());
                }
                else if (DayOfWeek == DayOfWeek.Tuesday)
                {
                    if (Hour < 12)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForLT());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new SchoolListForAC());
                        Global.Reports.Add(new SchoolListForAM());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new TeacherStatusForLT());
                    }
                }
                else if (DayOfWeek == DayOfWeek.Friday)
                {
                    if (Hour < 12)
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(true));
                        Global.Reports.Add(new EssayPendingReportForAM(true));
                        Global.Reports.Add(new StudentStatusReportForAC(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForAM(StudentStatusReportForAC.DisplayTable.partial));
                        Global.Reports.Add(new StudentStatusReportForStudent());
                        Global.Reports.Add(new TeacherStatusForLT());
                        Global.Reports.Add(new BoardIssueReport());
                    }
                    else
                    {
                        Statistics.RunType = RunType.full;
                        Global.Reports.Add(new EssayPendingReportForAC(false));
                        Global.Reports.Add(new EssayPendingReportForAM(false));
                        Global.Reports.Add(new TeacherStatusForLT());
                    }
                }
            }
            else
            {
                Statistics.RunType = RunType.skip;
            }
        }
    }

    public class Guidance_Scheduler : Scheduler
    {
        public override void Initizlize()
        {
            Statistics.ApplicationType = ApplicationType.guidance;
        }

        public override void Set()
        {
            DateTime Today = DateTime.Now;

            Global.Reports.Clear();

            if (Today.DayOfWeek == DayOfWeek.Tuesday || Today.DayOfWeek == DayOfWeek.Friday || Today.Day == 6)
            {
                Statistics.RunType = RunType.full;
                Global.Reports.Add(new GuidanceStudentStatusForAC());
                Global.Reports.Add(new GuidanceStudentStatusForAM());
            }
            else
            {
                Statistics.RunType = RunType.full;
            }
        }
    }
}
